<?php 
	include_once 'dataservice.php';
	include_once 'thuvienham.php';

	class gmail_db 
	{
		public function Them($TenDangNhap, $MatKhau, $ChuDe, $ThongBaoLoi)
		{
			$sql = "INSERT INTO `tbl_gmail`(`TenDangNhap`, `MatKhau`, `ChuDe`, `ThongBaoLoi`)
					VALUES ('$TenDangNhap', '$MatKhau', '$ChuDe', '$ThongBaoLoi')";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function Xoa($TenDangNhap)
		{
			$sql = "DELETE FROM `tbl_gmail` WHERE `TenDangNhap` = '$TenDangNhap'";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function CapNhat($TenDangNhap, $MatKhau, $ChuDe, $ThongBaoLoi)
		{
			$sql = "UPDATE `tbl_gmail`
					SET `MatKhau` = '$MatKhau', `ChuDe` = '$ChuDe', `ThongBaoLoi` = '$ThongBaoLoi'
					WHERE `TenDangNhap` = '$TenDangNhap'";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function LayDanhSach($TenDangNhap, $MatKhau, $ChuDe, $ThongBaoLoi)
		{
			$sql = "SELECT * FROM `tbl_gmail` WHERE 1  ";
			if($TenDangNhap != "")
				$sql .= " AND `TenDangNhap` = '$TenDangNhap' ";

			if($MatKhau != "")
				$sql .= " AND `MatKhau` = '$MatKhau' ";

			if($ChuDe != "")
				$sql .= " AND `ChuDe` = '$ChuDe' ";

			if($ThongBaoLoi != -1)
				$sql .= " AND `ThongBaoLoi` = '$ThongBaoLoi' ";

			$service = new dataservice();
			return $service->ExecuteQuery($sql);
		}

	}

